<?php


namespace app\shop\controller\admin;


use think\Request;
use app\shop\controller\BaseAdminController;
use app\shop\model\user\DesignScoreModel;
use app\shop\model\user\UserModel;
use think\App;

class DesignScoreController extends BaseAdminController
{
    public function __construct(App $app)
    {
        $this->model = new DesignScoreModel();
        $this->withModel = ['user', 'orders'];
        $this->search = $this->setSearch($app->request);
        parent::__construct($app);
    }

    public function setSearch(Request $request)
    {
        $where = [];
        $designName = $request->param('design_name', '', 'trim');
        if ($designName) {
            $designId = UserModel::where('realname', 'like', "%{$designName}%")->column('user_id');
            $where[] = ['user_id', 'in', $designId];
        }
        return [
            'custom' => $where
        ];
    }
}